package leetcode.view0502;

public class Solution {
	public String printBin(double num) {
		StringBuffer ans = new StringBuffer();
		ans.append("0.");
		while (ans.length() < 32 && num > 0) {
			num *= 2;
			int add = (int) num;
			ans.append(add);
			num -= add;
		}
		return ans.length() < 32 ? ans.toString() : "ERROR";
	}
}
